package com.zkl.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


/**
 * 日期格式化工具
 * @author guwenbin
 *
 */
public class DateUtil {
	
	
	public static final String DATE ="yyyy-MM-dd";
	
	public static final String DATE_TIME ="yyyy-MM-dd HH:mm:ss";
	
	private static final SimpleDateFormat date_fmt = new SimpleDateFormat(DATE);
	
	private static final SimpleDateFormat datetime_fmt = new SimpleDateFormat(DATE_TIME);
	
	private static final int [] week = {7,1,2,3,4,5,6};
	
	private static final String [] week_cn = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};

	/**
	 * 获取日期
	 * @return 新建的一个日期对象
	 */
	public static Date getDate(){
		return new Date();
	}
	
	/**
	 * 通过日期获取字符串格式 yyyy-MM-dd
	 * @return 
	 */
	public static String getDateString(){
		Date date = getDate();
		return date_fmt.format(date) ;
	}
	
	/**
	 * 通过日期获取字符串格式   yyyy-MM-dd HH:mm:ss
	 * @return
	 */
	public static String getDateTimeString(){
		Date date = getDate();
		return datetime_fmt.format(date) ;
	}
	
	/**
	 * 获取系统的当前礼拜几
	 * @author GWB
	 * time：2016年9月19日
	 */
	public static int whatWeekday(Date date) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		return week[c.get(Calendar.DAY_OF_WEEK)-1];
	}
	
	/**
	 * 获取系统的当前礼拜几  
	 * @param date
	 * @return 礼拜几  
	 */
	public static String whatWeekday_cn(Date date){
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		return week_cn[c.get(Calendar.DAY_OF_WEEK)-1];
	}
	
	public static void main(String[] args) {
		String aa = whatWeekday_cn(getDate());
		System.out.println(aa);
	}
}
